Conversation
There was a problem hiding this comment.
Pull request overview
Adds new integration test coverage for the AZIHSM OpenSSL provider, including a new C++/EVP-based test crate for session-only keys and a Rust/lit-based shell-script suite, plus CI wiring to run them.
Changes:
- Add
provider-testscrate that builds/runs C++ GoogleTest cases exercising the provider via the OpenSSL EVP API. - Add
integration-testscrate to run existing/new CLI-oriented provider tests vialitand bash scripts. - Update CI and xtask tooling to run the new integration suites; adjust RSA-PSS saltlen handling in the provider.
Reviewed changes
Copilot reviewed 60 out of 60 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| xtask/src/main.rs | Registers a new xtask command for integration tests. |
| xtask/src/integration_tests.rs | Adds an xtask to run the integration-tests crate. |
| xtask/src/coverage.rs | Updates workspace coverage invocation to exclude integration-tests. |
| provider-tests/cpp/utils/provider_ctx.hpp | RAII OpenSSL provider/libctx loader used by C++ tests. |
| provider-tests/cpp/utils/ossl_helpers.hpp | OpenSSL smart-pointer helpers for C++ tests. |
| provider-tests/cpp/utils/keygen_helpers.hpp | EC/RSA session key helper routines for C++ EVP tests. |
| provider-tests/cpp/tests.rs | Rust libtest-mimic harness to discover/run the C++ gtests. |
| provider-tests/cpp/smoke_tests.cpp | Basic provider load/name smoke tests. |
| provider-tests/cpp/rsa_session_sign_verify_tests.cpp | RSA session-key sign/verify (PKCS#1 + PSS) tests. |
| provider-tests/cpp/rsa_session_encrypt_decrypt_tests.cpp | RSA session-key OAEP encrypt/decrypt tests. |
| provider-tests/cpp/ecdh_session_keyexch_tests.cpp | ECDH session-key derive tests (buffer + file + negative). |
| provider-tests/cpp/ec_session_sign_verify_tests.cpp | EC session-key sign/verify tests across curves + negatives. |
| provider-tests/cpp/CMakeLists.txt | CMake build for the C++ gtest binary with pinned OpenSSL prefix. |
| provider-tests/build.rs | Cargo build script driving the CMake build of C++ tests. |
| provider-tests/Cargo.toml | Declares the provider-tests crate and its custom test target. |
| plugins/ossl_prov/src/azihsm_ossl_signature_rsa.c | Extends RSA-PSS saltlen handling to cover “auto”. |
| integration-tests/testfiles/rsa/verify/verify_wrong_key.sh | Adds RSA wrong-key verification negative case. |
| integration-tests/testfiles/rsa/verify/verify_negative_tampered_data.sh | Adds RSA tampered-data verification negative case. |
| integration-tests/testfiles/rsa/verify/verify.sh | RSA verify script under provider CLI tests. |
| integration-tests/testfiles/rsa/sign/sign.sh | RSA sign script under provider CLI tests. |
| integration-tests/testfiles/rsa/rsa_pss_default_padding/round_trip.sh | RSA-PSS default-padding round trip script. |
| integration-tests/testfiles/rsa/rsa-pss-specific/verify.sh | RSA-PSS specific-parameter verify script. |
| integration-tests/testfiles/rsa/rsa-pss-specific/sign.sh | RSA-PSS specific-parameter sign script. |
| integration-tests/testfiles/rsa/round_trip/round_trip.sh | RSA sign/verify round trip script. |
| integration-tests/testfiles/rsa/pkcs1_encryption/pkcs1_encryption.sh | RSA PKCS#1 encryption/decryption script. |
| integration-tests/testfiles/rsa/oneshot_verify/oneshot_verify.sh | RSA one-shot verify (pkeyutl) script. |
| integration-tests/testfiles/rsa/oneshot_sign/oneshot_sign.sh | RSA one-shot sign (pkeyutl) script. |
| integration-tests/testfiles/rsa/oneshot_round_trip/oneshot_round_trip.sh | RSA one-shot sign+verify round trip script. |
| integration-tests/testfiles/rsa/oaep_encryption/oaep_encryption.sh | RSA OAEP encryption/decryption script. |
| integration-tests/testfiles/rsa/import_key/import_key_negative_invalid_path.sh | RSA import negative test for missing input key file. |
| integration-tests/testfiles/rsa/import_key/import_key.sh | RSA import test for masked key creation/loading. |
| integration-tests/testfiles/rsa/default_padding/round_trip.sh | RSA default-padding sign/verify round trip script. |
| integration-tests/testfiles/rsa/certificate/certificate.sh | RSA certificate generation script via provider key. |
| integration-tests/testfiles/env.sh | Shared environment setup for bash-based integration scripts. |
| integration-tests/testfiles/ec/verify/verify_negative_wrong_key.sh | EC wrong-key verification negative case. |
| integration-tests/testfiles/ec/verify/verify_negative_tampered_data.sh | EC tampered-data verification negative case. |
| integration-tests/testfiles/ec/verify/verify.sh | EC verify script under provider CLI tests. |
| integration-tests/testfiles/ec/verify/oneshot_verify.sh | EC one-shot verify (pkeyutl) script. |
| integration-tests/testfiles/ec/sign/sign.sh | EC sign script under provider CLI tests. |
| integration-tests/testfiles/ec/sign/oneshot_sign.sh | EC one-shot sign (pkeyutl) script. |
| integration-tests/testfiles/ec/round_trip/round_trip_import.sh | EC import + sign/verify round trip script. |
| integration-tests/testfiles/ec/round_trip/round_trip.sh | EC sign/verify round trip script. |
| integration-tests/testfiles/ec/import_key_sec1/import_key_sec1.sh | EC SEC1 import script. |
| integration-tests/testfiles/ec/import_key/import_key_negative_invalid_path.sh | EC import negative test for missing input key file. |
| integration-tests/testfiles/ec/import_key/import_key.sh | EC import test for masked key creation/loading. |
| integration-tests/testfiles/ec/hmac/hmac.sh | ECDH→HKDF-derived HMAC compute script. |
| integration-tests/testfiles/ec/hkdf_key_derivation/hmac_key_derivation.sh | HKDF derivation for HMAC key material script. |
| integration-tests/testfiles/ec/hkdf_key_derivation/hkdf_key_derivation.sh | HKDF derivation for AES key material script. |
| integration-tests/testfiles/ec/ecdh_key_exchange/ecdh_key_exchange.sh | ECDH derive-to-file script. |
| integration-tests/testfiles/ec/ecdh_hkdf_hmac_roundtrip/ecdh_hkdf_hmac_roundtrip.sh | ECDH→HKDF→HMAC round trip script. |
| integration-tests/testfiles/ec/create_key/create_key_negative.sh | EC create-key negative (invalid curve) script. |
| integration-tests/testfiles/ec/create_key/create_key.sh | EC create-key script with session/usage variations. |
| integration-tests/testfiles/ec/certificate/certificate.sh | EC certificate generation script via provider key. |
| integration-tests/testfiles/digest/digest.sh | Digest correctness script vs default provider. |
| integration-tests/src/lib.rs | Rust test runner invoking lit across script directories/variants. |
| integration-tests/Cargo.toml | Declares the integration-tests crate and dependencies. |
| integration-tests/.gitignore | Ignores integration test artifacts produced by scripts. |
| Cargo.toml | Adds integration-tests and provider-tests to the workspace. |
| .github/workflows/rust.yml | Adds a CI job to build OpenSSL/provider and run both integration suites. |
| .cargo/audit.toml | Ignores specific RustSec advisories for test-only transitive deps. |
plugins/ossl_prov/integration-tests/openssl-capi/cpp/algo/rsa/enc_dec_tests.cpp
Show resolved
Hide resolved
plugins/ossl_prov/integration-tests/openssl-capi/cpp/utils/keygen_helpers.hpp
Show resolved
Hide resolved
plugins/ossl_prov/integration-tests/openssl-capi/cpp/algo/ec/keyexch_tests.cpp
Show resolved
Hide resolved
c068c98 to
a80f71d
Compare
plugins/ossl_prov/integration-tests/openssl-capi/cpp/algo/ec/keyexch_tests.cpp
Show resolved
Hide resolved
plugins/ossl_prov/integration-tests/openssl-cli/src/openssl_cli_tests.rs
Show resolved
Hide resolved
plugins/ossl_prov/integration-tests/openssl-capi/cpp/utils/keygen_helpers.hpp
Show resolved
Hide resolved
plugins/ossl_prov/integration-tests/openssl-capi/cpp/algo/rsa/enc_dec_tests.cpp
Outdated
Show resolved
Hide resolved
plugins/ossl_prov/integration-tests/openssl-capi/cpp/capi_gtest_runner.rs
Outdated
Show resolved
Hide resolved
a37f841 to
201b89b
Compare
plugins/ossl_prov/integration-tests/openssl-capi/cpp/utils/provider_ctx.hpp
Show resolved
Hide resolved
plugins/ossl_prov/integration-tests/openssl-capi/cpp/openssl_capi_integration_tests.rs
Show resolved
Hide resolved
plugins/ossl_prov/integration-tests/openssl-capi/cpp/utils/keygen_helpers.hpp
Show resolved
Hide resolved
rajesh-gali
left a comment
There was a problem hiding this comment.
please update readme with instructions to run the tests
72458d6 to
63efd74
Compare
63efd74 to
8812d80
Compare
8812d80 to
4e60127
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 25 out of 65 changed files in this pull request and generated 1 comment.
You can also share your feedback on Copilot code review. Take the survey.
plugins/ossl_prov/integration-tests/openssl-capi/cpp/utils/keygen_helpers.hpp
Outdated
Show resolved
Hide resolved
Signed-off-by: Jens Topp <jens.topp@9elements.com>
Signed-off-by: Jens Topp <jens.topp@9elements.com>
Signed-off-by: Jens Topp <jens.topp@9elements.com>
Signed-off-by: Jens Topp <jens.topp@9elements.com>
Signed-off-by: Jens Topp <jens.topp@9elements.com>
1f307aa to
80b6989
Compare
Signed-off-by: Jens Topp <jens.topp@9elements.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 26 out of 66 changed files in this pull request and generated 2 comments.
You can also share your feedback on Copilot code review. Take the survey.
Signed-off-by: Jens Topp <jens.topp@9elements.com>
Signed-off-by: Jens Topp <jens.topp@9elements.com>
Signed-off-by: Jens Topp <jens.topp@9elements.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 66 out of 67 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (2)
plugins/ossl_prov/integration-tests/openssl-cli/testfiles/env.sh:74
- This script writes
credentials_id.bin/credentials_pin.bininto$AZIHSM_KEY_DIR, but the provider’s documented fallback is to read these files from the current working directory (e.g../credentials_id.bin). The surrounding comments still describe a CWD-based fallback, which is no longer accurate for the CLI scripts unless they run with CWD set to$AZIHSM_KEY_DIRor the files are copied/symlinked there. Consider updating the comments (or placing the fallback files in CWD) to match actual behavior.
.github/workflows/rust.yml:133 - CI now builds OpenSSL with shared libraries and builds
azihsm_api_nativewithoutOPENSSL_STATIC=1/no-shared -fvisibility=hidden, butplugins/ossl_prov/README.md’s build instructions statelibazihsm_api_native.somust be built against a static OpenSSL to avoid a circular dependency when the provider is loaded bylibcrypto. Please either (a) restore the static-OpenSSL build flags/env in this workflow, or (b) update the README/build guidance to reflect the new supported shared-OpenSSL approach.
./Configure --prefix=/opt/openssl-3.0.3 --libdir=lib \
-fPIC
make -j"$(nproc)"
sudo make install_sw
- name: Build azihsm with OpenSSL
env:
OPENSSL_DIR: /opt/openssl-3.0.3
run: |
cargo build -p azihsm_api_native --features mock
cargo build -p azihsm_ossl_provider --features mock
You can also share your feedback on Copilot code review. Take the survey.
plugins/ossl_prov/integration-tests/openssl-capi/cpp/capi_gtest_runner.rs
Outdated
Show resolved
Hide resolved
plugins/ossl_prov/integration-tests/openssl-capi/cpp/utils/keygen_helpers.hpp
Show resolved
Hide resolved
Signed-off-by: Jens Topp <jens.topp@9elements.com>
|
|
||
| [[test]] | ||
| harness = false | ||
| name = "capi_gtest_runner" |
There was a problem hiding this comment.
can we rename the binary to something "openssl_capi_integration_tests" to align with other executables.
Signed-off-by: Jens Topp <jens.topp@9elements.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 66 out of 67 changed files in this pull request and generated 3 comments.
You can also share your feedback on Copilot code review. Take the survey.
plugins/ossl_prov/integration-tests/openssl-capi/cpp/utils/keygen_helpers.hpp
Show resolved
Hide resolved
Signed-off-by: Jens Topp <jens.topp@9elements.com>
|
@rajesh-gali here I tried to write up the problem I was facing during the development of the test suite (CLI and CAPI) with usage of the config file Provider double-init / deadlock: the core problem and how the test suites avoid itWhat
|
| Suite | Strategy | Why no double-init |
|---|---|---|
| CLI | Shared libcrypto | One libcrypto.so.3 instance; provider calls re-enter the same already-initialized library — no second auto-init possible |
| CAPI | NO_LOAD_CONFIG + per-test OSSL_LIB_CTX |
Default context never loads provider; config loaded explicitly into isolated contexts — safe regardless of static/shared linking |
The CAPI approach is inherently safe regardless of static/shared linking because it never lets the default context auto-load the provider. The CLI approach depends on shared linking to avoid the recursive init.
Annotated call stacks
CLI test suite
1. Rust test runner (nextest) invokes bash script
e.g. plugins/ossl_prov/integration-tests/openssl-cli/testfiles/ec/round_trip/round_trip.sh
2. Script sources env.sh
plugins/ossl_prov/integration-tests/openssl-cli/testfiles/env.sh
├── Generates key material in $REPO_ROOT/target/test-keymat/cli/ (lines 59-87)
├── Generates openssl.cnf with activate=1 for azihsm provider (lines 95-119)
│ └── module = <absolute path to azihsm_provider.so>
│ └── activate = 1
└── export OPENSSL_CONF="$AZIHSM_KEY_DIR/openssl.cnf" (line 121)
3. Script calls $OPENSSL_BIN (e.g. genpkey, dgst)
└── openssl binary starts
└── libcrypto.so.3 config loading (OPENSSL_INIT_LOAD_CONFIG)
└── reads OPENSSL_CONF
└── activate=1 → OSSL_PROVIDER_load("azihsm")
└── dlopen(azihsm_provider.so)
└── OSSL_provider_init()
└── provider uses EVP_* calls → same libcrypto.so.3
(shared linking: single instance, already initialized,
no recursion)
4. openssl CLI executes the cryptographic operation (genpkey/dgst/req)
using the now-loaded azihsm provider via -propquery "?provider=azihsm"
Key requirement: OpenSSL must be built with shared libraries so the binary and provider share one libcrypto.so.3. CI builds OpenSSL with ./Configure --prefix=/opt/openssl-3.0.3 --libdir=lib -fPIC (.github/workflows/rust.yml:122-123).
CAPI test suite
1. Rust test runner discovers gtest binary and enumerates tests
plugins/ossl_prov/integration-tests/openssl-capi/cpp/openssl_capi_integration_tests.rs
├── Generates key material in $REPO_ROOT/target/test-keymat/capi/ (generate_dev_key_material())
├── Generates openssl.cnf with activate=1 (generate_openssl_conf())
└── Calls gtest binary with --gtest_list_tests, parses output (parse_gtest_list())
└── Passes OPENSSL_CONF to each subprocess via .env() (lines 336, 408)
2. For each test, Rust runner invokes the gtest binary with --gtest_filter=Suite.Test
3. gtest binary main() runs BEFORE any test
plugins/ossl_prov/integration-tests/openssl-capi/cpp/main.cpp:13
└── OPENSSL_init_crypto(OPENSSL_INIT_NO_LOAD_CONFIG, NULL)
└── Marks default context: SKIP config auto-loading
(OPENSSL_CONF is in env but default context will never read it)
4. Individual test creates ProviderCtx (RAII)
plugins/ossl_prov/integration-tests/openssl-capi/cpp/utils/provider_ctx.hpp:23-68
├── OSSL_LIB_CTX_new() (line 25)
│ └── Creates a fresh, isolated library context (not the default)
├── std::getenv("OPENSSL_CONF") (line 35)
└── OSSL_LIB_CTX_load_config(libctx_, conf) (line 44)
└── Loads config INTO the isolated context only
└── activate=1 → OSSL_PROVIDER_load("azihsm") into libctx_
└── Provider initializes in isolated context
└── Provider's OpenSSL API calls use the process-wide libcrypto
but the DEFAULT context was never loaded with provider config
→ no recursive activation, no deadlock
5. Test runs cryptographic operations against ProviderCtx::libctx()
e.g. EVP_PKEY_CTX_new_from_name(libctx, "EC", "?provider=azihsm")
6. ProviderCtx destructor (~ProviderCtx) (line 70-76)
└── OSSL_LIB_CTX_free(libctx_)
└── Unloads provider, releases all resources for that context
Key requirement: OPENSSL_INIT_NO_LOAD_CONFIG must be called before any other OpenSSL API use. This is why it's in main() before InitGoogleTest. The per-test OSSL_LIB_CTX isolation also ensures tests don't interfere with each other.
|
Closed with respect to #266 |
Add a provider-tests crate that exercises the azihsm provider through
the OpenSSL EVP API (not the CLI tool), enabling testing of session-based
ephemeral keys that cannot be tested via the command line.
Tests added:
Additional coverage added in follow-up commits: